<?php
define('__ROOT__', dirname(dirname(__FILE__))); 
include_once(__ROOT__.'../../includes/header.php'); 
include_once(__ROOT__.'../../includes/leftnav.php');
?>
<div id="content" class="span10">
	<ul class="breadcrumb">
	<li>
		<a href="<?php echo base_url('/home'); ?>">Home</a> <span class="divider">/</span>
	</li>
	<li>
		<a href="<?php echo base_url('/admin/dashboard'); ?>">Dashboard</a><span class="divider">/</span>
	</li>
	<li>
		<a href="<?php echo base_url('/admin/property/view'); ?>">Property</a><span class="divider">/</span>
	</li>
	<li>
		Post Property Ad
	</li>
</ul>
	<?php $attributes = array('class' => 'form-horizontal' , 'id' => 'propertyfrm');
		if (isset($message))
			echo $message ;
		echo form_open_multipart($action, $attributes);
		echo "<span class=\"error\">";
		echo validation_errors();
		echo "</span>";
		?>
		<fieldset>
			<legend>Contact Information</legend>
			<div class="row-fluid">
				<div class="span4">
					<label>Contact Person<sup class="error">*</sup></label> 
					<input id="contact_person" name="contact_person" class="span10" type="text" value="<?php echo set_value('contact_person', isset($user['displayName']) ? $user['displayName'] : $user['name']); ?>">
					
				</div>
				<!--/span-->
				<div class="span4">
					<label>Contact No<sup class="error">*</sup></label>
					<input id="contact_no"
						class="span10" type="text" name="contact_no"  value="<?php echo set_value('contact_no',$user['phone']); ?>">
				</div><!--/span-->
				</div><!-- /row -->
				<div class="row-fluid">
				<div class="span4">
					<label>Email<sup class="error">*</sup></label> <input id="contact_email" name="contact_email" type="text" class="span10"
						placeholder="user@example.com" value="<?php echo set_value('contact_email', $user['email']); ?>">
				</div>
				<div class="span4">
					<label>Expired On</label>
					<input id="expired_date" name="expired_date" type="text" class="span10"
						placeholder="DD/MM/YYYY" value="<?php echo set_value('expired_date', $expired_date); ?>">
				</div>
				<!--/span-->
			</div><!-- /row -->
		</fieldset>
	
		<fieldset>
			<legend>Property details</legend>
			<div class="row-fluid">
				<div class="span5">
					<label>Title<sup class="error">*</sup></label> 
					<input type="text" class="span12"
						placeholder="type your advertisement's title here" name="ptitle" id="ptitle" value="<?php echo set_value('ptitle'); ?>">
					<span class="error"></span>
				</div>
				<!--/span-->
				<div class="span3">
					<label>Property Type<sup class="error">*</sup></label>
					<select id="propType" name="propType" data-rel="chosen" title="Please select something!">
						<?php
						foreach ($catg as $key => $value) {
							echo '<option value="' . $key . '"';
							if (isset($selectedCatg)){
								if ((int)$selectedCatg  === (int)$key)
									echo 'selected ';
								}
							echo '>';
							echo $value;
							echo '</option>';

						}
						
						?>
					</select>
					<span></span>
				</div>
				<!--/span-->
				<div class="span4">
					<label>Others</label> <input id="othcatg" name="othcatg" type="text" class="span10"
						placeholder="type category name" value="<?php echo set_value('othcatg'); ?>">
				</div>
				<!--/span-->
			</div>
			<!-- /row-->
			
			<!--/row-->
			<div class="row-fluid" style="margin-top: 20px; margin-bottom: 20px;">
				<div class="span6">
					<label style="width:60px">Price</label> 
					<input id="pprice" name="pprice"
						class="span6" value="<?php echo set_value('price'); ?>" type="text">
					<span>
					<select id="price_denote" name="price_denote" class="span3 right">
					  <option value="KS">KS</option>
					  <option value="LAKH" selected>LAKH</option>
					  <option value="USD">USD</option>
					  <option value="SGD">SGD</option>
					  <option value="CNY">CNY</option>
					</select>
					</span>
										
				</div>
				<div class="span2 left">
					<input style="margin-bottom:0px" id="isnegotaible" name="isnegotaible" type="checkbox" checked>Is Negotiable
				</div>
				<div class="span3">
					<select id="category" name="category" data-rel="chosen">
					  <option value="1">Sell</option>
					  <option value="2">Buy</option>
					  <option value="3">Rent</option>
					  <option value="4">Long tenture</option>
					</select>
				</div>
			</div>
			<div class="row-fluid">
				<!--/span-->
				<div class="span4">
					<label>Bed Rooms<sup class="error">*</sup></label>
					<input type="text" id="bedrm" name="bedrm" 
					vlaue="<?php echo set_value('bedrm'); ?>" class="span6">	 
				</div>
				<!--/span-->
				<div class="span4">
					<label>Bath Rooms<sup class="error">*</sup></label>
					<input type="text" id="bathrm" 
					name="bathrm" value="<?php echo set_value('bathrm'); ?>" class="span6">	 
				</div>

				<div class="span4">
					<label>Living Rooms<sup class="error">*</sup></label>
					<input type="text" id="livingrm" 
					name="livingrm" value="<?php echo set_value('livingrm'); ?>" class="span6">	 
				</div>
				<!--/span-->
			</div>
			<div class="row-fluid">
				<div class="span4">
					<label>Square ft</label>
					<input type="text" id="squareft" name="squareft" 
					value="<?php echo set_value('squareft'); ?>" class="span6">	 
				</div>
				<!--/span-->
				<div class="span4">
					<label>Floor No</label>
					<input type="text" id="floorno" 
					name="floorno" value="<?php echo set_value('floorno'); ?>" class="span6">	 
				</div>
				<!--/span-->
				<div class="span4">
					<label>Facing</label>
					<input type="text" id="facing" 
					name="facing" value="<?php echo set_value('facing'); ?>" class="span6">	 
				</div>
				<!--/span-->
			</div>
			<div class="row-fluid">
				<div class="span4">
					<label>Furnished</label>
					<input type="text" id="furnished" name="furnished" 
					value="<?php echo set_value('furnished'); ?>" class="span6">	 
				</div>
				<!--/span-->
				<div class="span4">
					<label>Years Old</label>
					<input type="text" id="yearsold" 
					name="yearsold" value="<?php echo set_value('yearsold'); ?>" class="span6">	 
				</div>
				<!--/span-->
			</div>
			<div class="row-fluid">
				<div class="span12">
					<label>Add Images</label> <input data-no-uniform="true"
						type="file" name="userfile[]" id="file_upload" multiple="multiple" />
					<p class="help-block">Choose muliple files (Maximum 4 images)</p>
				</div>
			</div>
		</fieldset>
		<fieldset>
			<legend>Location</legend>
			<div class="row-fluid">
				<div class="span6">
					<div class="row-fluid">
						<div class="span5">
							<label>Address Line - 1</label> 
							<textarea row="3"
								placeholder="type the address" name="address1" id="address1" value="<?php echo set_value('address1'); ?>"></textarea>
							<span class="error"></span>
						</div>
					</div>
					<div class="row-fluid">
						<div class="span5">
							<label>Address Line - 2</label> 
							<textarea rows="3" placeholder="type the address" name="address2" id="address2" value="<?php echo set_value('address2'); ?>"></textarea>
							<span class="error"></span>
						</div>
					</div>
					<div class="row-fluid">
						<div class="span5">
							<label>Country</label> 
							<select name="country" id="countries_states1" class="input-medium bfh-countries" data-country="MM">"<?php echo set_value('country'); ?>"</select>
						</div>
						<div class="span3">
							<label>City/State</label> 
							<select name="city" class="input-large bfh-states" data-country="countries_states1">"<?php echo set_value('city'); ?>"</select>
						</div>
						
						<div class="span8">
						<br/>
						<strong>Enter Details information of property<sup class="error">*</sup></strong>
						<label><textarea class="cleditor" id="pdescriptions" 
						name="pdescriptions" rows="2" style="font: 8.5pt Zawgyi-One;">
								<?php echo set_value('pdescriptions'); ?>
							</textarea></label>
						</div>
						<div id="descErr">
							<span class="error"></span>
						</div>
					</div>
				</div>
				
				<div class="span6">
					<div class="row-fluid">
						<div class="span12">
						<label>Display on Map?</label> 
							<input type="text" class="span10"
								placeholder="Yan Aung Street, Sanchaung Township, Yangon, Burma" name="addresspicker_map" id="addresspicker_map" value="<?php echo set_value('addresspicker_map'); ?>">
						<span class="help-block">Please choose autocomplete suggestion.</span>
						</div>
						<input type="hidden" id="lat" value="" name="lat" />
						<input type="hidden" id="lng" value="" name="lng" />
					</div>
					<div id="map" style="height:450px;"></div>
				</div>
			</div>
			</fieldset>
			
		</fieldset>
		<fieldset>
			<div class="form-actions">
				<button type="submit" class="btn btn-primary">Submit</button>
				<button class="btn">Cancel</button>
			</div>
		</fieldset>
		
		<?php echo form_close(); ?>
</div>

<?php include_once(__ROOT__.'../../includes/footer.php');?>
echo '<script src="';
		echo base_url("assets/js/jquery.ui.addresspicker.js");
		echo '"></script>';
<script type="text/javascript">
	$(document).ready(function(){
		var addresspickerMap = $( "#addresspicker_map" ).addresspicker({
		  elements: {
		    map:      "#map",
		    lat:      "#lat",
		    lng:      "#lng"
		  }
		});
		var gmarker = addresspickerMap.addresspicker( "marker");
		gmarker.setVisible(true);
		addresspickerMap.addresspicker( "updatePosition");
		
	});
</script>

